package com.hrpmar.utils;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by 李松松 on 2017/10/30.
 */
@WebFilter("/*")
public class SystemFilter implements Filter{

    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
       try{
           HttpServletRequest req = (HttpServletRequest)servletRequest;
           HttpSession session=req.getSession();
           SystemContext.setHttpSession(session);
           filterChain.doFilter(servletRequest,servletResponse);
       }finally {
           SystemContext.removeSessionT();
       }
    }

    public void destroy() {

    }
}
